package com.gomokult.servlet.user;

import com.gomokult.exception.UserRegisteredException;
import com.gomokult.service.impl.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
/**
 * 文件：DeleteCommentServlet.java
 * 作者：赵哲群
 * 完成度：已完成
 * 最后修改日期：2023-7-6
 */
@WebServlet("/servlet/RegisterUserServlet")
public class RegisterUserServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String email = request.getParameter("email");
        String nickname = request.getParameter("nickname");
        String password = request.getParameter("password");
        try {
            UserServiceImpl.getSingleton().registerUser(email,nickname,password);
        } catch (UserRegisteredException e) {
            out.print("⚠ 该邮箱已被注册");
        } finally {
			out.close();
		}
    }
}
